Ext.define('wmf.lib.GridPanel', {
	extend: 'Ext.grid.Panel',
	alias: 'widget.WmfGridPanel',
	initComponent: function() {
		var me = this;
		var callparent = false;
		
		if(!me.columns) {
			if(me.columnfields && me.columnaction) {
				me.columns = Ext.Array.merge(me.columnfields, me.columnaction);	
			} else {
				if(me.columnfields)
					me.columns = me.columnfields;	
			}	
		}
		
		if(me.useRefresh === true) {
			if(me.dockedItems && me.dockedItems[0].items) {
				me.dockedItems[0].items = Ext.Array.merge(me.dockedItems[0].items,
				[{
					xtype: 'button',
					itemId: 'baserefresh',
					iconCls: 'icon-synchro',
					text: translations.global.operation.refresh
				}]);
			} else {
				me.dockedItems = [{
					xtype : 'toolbar',
					dock : 'top',
					layout : {
						type : 'hbox'
					},
					items : [{
						xtype: 'button',
						itemId: 'baserefresh',
						iconCls: 'icon-synchro',
						text: translations.global.operation.refresh
					}]
				}];	
			}	
		}
			
	
		if(!(me.showPager === false)) {
			var store = me.getStore();
			this.bbar = new Ext.container.Container({
				layout: 'anchor',
				frame: false,
				border: 0,
				defaults: {anchor: '100%'},
				defaultType: 'toolbar'
			});
			var pagebar = new Ext.PagingToolbar({
				store: store,
				frame: false,
	            border: 0,
	            displayInfo: true,
	            emptyMsg: '没有记录',
	            displayMsg: '显示记录 {0} - {1} 共 {2}'
			});
			
			this.bbar.add(pagebar);
			this.callParent(arguments);
			callparent = true;
			this.getStore().pagebar = pagebar;
			if(me.pageSize !== undefined && me.pageSize>0) {
				this.getStore().defaultPageSize = me.pageSize;	
			}
		} else {
			this.callParent(arguments);
			callparent = true;
		}
		
		if(!callparent)
			this.callParent(arguments);
		}
});
